﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using AMS.Core.Data;
using AMS.DD35.DbAccess;
using AMS.Core.Services;
using AMS.Core;

namespace AMS.DD35.ServiceLib.Services
{
    public class RegisterService : IRegisterService
    {
        private IRegisterConnector _register;

        public RegisterService(IRegisterConnector registerConnector)
        {
            this._register = registerConnector;
        }

        public void AttemptRegister(RegistrationData data)
        {
            if (_register.UsernameExists(data.LoginData.Username))
            {
                ExceptionHandler.Exception("username exists");
                return;
            }

            _register.InsertUserInfo(data.LoginData.Username, data.LoginData.PasswordHash, data.EmailAddress);
        }
    }
}
